const app = new Vue({
el: "#justOneDay",
template:`
`,
data() {
return {
countdownTime: '',
justOneDay: []
}
},
created() {
this.updateCountdown();
this.countdownInterval = setInterval(this.updateCountdown, 1000);
},
beforeDestroy() {
clearInterval(this.countdownInterval);
},
mounted() {
this.getJustOneDay();
},
methods: {
updateCountdown() {
const now = new Date();
const nextMidnight = new Date();
nextMidnight.setHours(23, 59, 59, 0);
const timeDifference = nextMidnight - now;
const hours = String(Math.floor((timeDifference / (1000 * 60 * 60)) % 24)).padStart(2, '0');
const minutes = String(Math.floor((timeDifference / (1000 * 60)) % 60)).padStart(2, '0');
const seconds = String(Math.floor((timeDifference / 1000) % 60)).padStart(2, '0');
this.countdownTime = `${hours}:${minutes}:${seconds}`;
},
async getJustOneDay() {
try {
// const response = await fetch(`http://gateway.dev.10x10aws.net/cache/apis/product/just1day/PC`);
const response = await fetch(`https://gateway.10x10.co.kr/cache/apis/product/just1day/PC`);
if (response.ok) {
const json = await response.json();
if (json.status === 200) {
this.justOneDay = json.result;
console.log(this.justOneDay)
}
}
} catch (e) {}
},
moveToItem(itemId) {
location.href = 'shopping/category_prd.asp?itemid=' + itemId;
}
},
});